package com.itheima.search.controller;

import com.itheima.search.domain.NewsVO;
import com.itheima.search.domain.SearchParam;
import com.itheima.search.domain.SearchResult;
import com.itheima.search.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/search")
public class SearchController {

    @Autowired
    private SearchService searchService;

    //搜索商品
    @PostMapping
    public SearchResult search(@RequestBody SearchParam searchParam) {
        return searchService.search(searchParam);
    }

    //根据id查询新闻详细内容
    @GetMapping("/{newsId}")
    public NewsVO getNewsById(@PathVariable String newsId) {
        return searchService.getById(newsId);
    }
}
